<template>
	<view style="display: flex;flex-direction: row;">
		<!-- 管理功能选项栏 -->
		<view style="display: flex;flex-direction: column;width: 220upx;background-color: #001529;">
			<image src="../../static/admin.png" mode="aspectFill" class="admin_pic"></image>
			<view v-for="(item,index) in functionList" :key=index>
				<view
					style="margin-top: 20upx;padding: 20upx;width: 180upx;display: flex;flex-direction: row;color: #FFFFFF;font-size: 15px;align-items: center;">
					<image :src="item.icon" style="width: 15upx;height: 15upx;margin-right: 5upx;"></image>
					{{item.name}}
					<image src="../../static/arrow.png" class="arrow"></image>
				</view>
				<view v-for="(items,indexs) in item.page" @click="menu_change(items)" :key=indexs
					:class="menu_id==items.id?'choose_detail':'detail'">
					{{items.name}}
				</view>
			</view>
		</view>
		<!-- 管理功能选项栏end -->
		<!-- 管理具体界面 -->
		<scroll-view scroll-y='true' style="background-color: #F6F8F9;width: 100%;height: 100vh;">
			<view
				style="box-shadow: -1px -1px 5px #888888;width: 100%;background-color: #FFFFFF;height: 50upx;display: flex;flex-direction: row;align-items: center;font-size: 17px;position: absolute;top: 0px;z-index: 99;">
				<image src="../../static/admin1.png" style="width: 20upx;height: 20upx;margin-left: 25upx;"></image>
				<view style="margin-left: 5upx;">
					后台管理
				</view>
				<view style="margin-left: 5upx;display: flex;justify-content: center;align-items: center;">
					<image src="../../static/arrow1.png" class="arrow1"></image>
				</view>
				<view style="margin-left: 5upx;">
					{{name}}
				</view>
				<image src="http://t7.baidu.com/it/u=1880899253,2364657333&fm=193"
					style="width: 40upx;height: 40upx;border-radius: 50%;margin-left: auto;"></image>
				<view style="color: #6C6E72;font-weight: bold;padding: 0 10upx 0 10upx;">
					admin
				</view>
				<image src="../../static/arrow2.png" class="arrow1" style="margin-right: 10upx;"></image>
			</view>
			<swiper :current='menu_id' disable-touch=true
				style="width: 100%;height: 100%;display: flex;justify-content: center;align-items: center;padding-top: 50rpx;">
				<swiper-item style="display: flex;justify-content: center;align-items: center;flex-direction: column;">
					<scroll-view scroll-y="true" style="height: 98vh;">
						<!-- 数据统计u-charts id=0 -->
						<RecomAdmin :PageNum='PageNum_shop' :pageList='pageList' :Num='Num_shop' :PersonList='ShopList'
							style="width: 100%;"></RecomAdmin>
						<!-- 数据统计end-->

					</scroll-view>

				</swiper-item>
				

				<swiper-item>
					<scroll-view scroll-y="true" style="height: 98vh;">
						<!-- 用户管理id=2 -->
						<person_admin :PageNum='PageNum_user' :Num='userNum' :PersonList='PersonList'
							style="margin-top: -30upx;width: 100%;height: 90%;display: flex;justify-content: center;align-items: center;">
						</person_admin>
						<!-- 用户管理end-->
					</scroll-view>

				</swiper-item>
				<swiper-item>
					<scroll-view scroll-y="true" style="height: 98vh;">
						<!-- 登录日志id=3 -->
						<login_log :PageNum='PageNum_login' :Num='loginNum' :LoginList='LoginList'
							style="margin-top: -30upx;width: 100%;height: 90%;display: flex;justify-content: center;align-items: center;">
						</login_log>
						<!-- 登录日志end-->
					</scroll-view>

				</swiper-item>
				<swiper-item>
					<scroll-view scroll-y="true" style="height: 98vh;">
						<!-- 帖子管理id=4 -->
						<poster_admin :PageNum='PageNum_poster' :Num='posterNum' :posterList='posterList'
							style="margin-top: -30upx;width: 100%;height: 90%;display: flex;justify-content: center;align-items: center;">
						</poster_admin>
						<!-- 帖子管理end-->
					</scroll-view>

				</swiper-item>
				<swiper-item>
					<scroll-view scroll-y="true" style="height: 98vh;">
						<!-- 评论管理id=5 -->
						<comment_admin :PageNum='PageNum_comment' :Num='commentNum' :CommentList='CommentList'
							style="margin-top: -30upx;width: 100%;height: 90%;display: flex;justify-content: center;align-items: center;">
						</comment_admin>
						<!-- 评论管理end-->
					</scroll-view>

				</swiper-item>
				<swiper-item>
					<scroll-view scroll-y="true" style="height: 120vh;">
						<!-- 计划管理id=6 -->
						<plan_admin :PageNum='PageNum_plan' :Num='Num_plan' :PlanList='PlanList'
							style="margin-top: -30upx;width: 100%;height: 90%;display: flex;justify-content: center;align-items: center;">
						</plan_admin>
						<!-- 计划管理end-->
					</scroll-view>

				</swiper-item>
				<swiper-item>
					<scroll-view scroll-y="true" style="height: 105vh;">
						<!-- 通用计划管理id=7 -->
						<commonPlan_admin :PageNum='PageNum_commonPlan' :Num='Num_commonPlan' :PlanList='commonPlanList'
							style="margin-top: -30upx;width: 100%;height: 90%;display: flex;justify-content: center;align-items: center;">
						</commonPlan_admin>
						<!-- 通用计划管理end-->
					</scroll-view>

				</swiper-item>
				<swiper-item>
					<scroll-view scroll-y="true" style="height: 105vh;">
						<!-- 健身计划管理id=8 -->
						<fitPlan_admin :PageNum='PageNum_fitPlan' :Num='Num_fitPlan' :PlanList='fitPlanList'
							style="margin-top: -30upx;width: 100%;height: 90%;display: flex;justify-content: center;align-items: center;">
						</fitPlan_admin>
						<!-- 健身计划管理end-->
					</scroll-view>

				</swiper-item>
				<swiper-item>
					<scroll-view scroll-y="true" style="height: 105vh;">
						<!-- 学习计划管理id=9 -->
						<studyPlan_admin :PageNum='PageNum_studyPlan' :Num='Num_studyPlan' :PlanList='studyPlanList'
							style="margin-top: -30upx;width: 100%;height: 90%;display: flex;justify-content: center;align-items: center;">
						</studyPlan_admin>
						<!-- 学习计划管理end-->
					</scroll-view>

				</swiper-item>
			</swiper>

		</scroll-view>
		<!-- 管理具体界面end -->

	</view>
</template>

<script>
	import uniPopup from "@/components/uni-popup/uni-popup.vue"
	import person_admin from "@/components/admin-components/person_admin.vue"
	import shopping_admin from "@/components/admin-components/shopping_admin.vue"
	import RecomAdmin from "@/components/admin-components/RecomAdmin"
	import poster_admin from "@/components/admin-components/poster_admin.vue"
	import plan_admin from "@/components/admin-components/plan_admin.vue"
	import bug_log from "@/components/admin-components/bug_log.vue"
	import commonPlan_admin from "@/components/admin-components/commonPlan_admin.vue"
	import fitPlan_admin from "@/components/admin-components/fitPlan_admin.vue"
	import studyPlan_admin from "@/components/admin-components/studyPlan_admin.vue"
	import login_log from "@/components/admin-components/login_log.vue"
	import comment_admin from "@/components/admin-components/comment_admin.vue"

	export default {
		components: {
			uniPopup,
			person_admin,
			shopping_admin,
			RecomAdmin,
			poster_admin,
			plan_admin,
			bug_log,
			commonPlan_admin,
			fitPlan_admin,
			studyPlan_admin,
			login_log,
			comment_admin
		},
		data() {
			return {
				menu_id: 0,
				search_word: '',
				add_accout: '',
				add_password: '',
				choose_all_: false,
				checkbox_status: [],
				checkbox: false,
				accout: '',
				password: '',
				person_id: 1,
				add_time: '',
				input_confirm: -1,
				NowPage: 1,
				name: '人员管理',
				functionList: [{
						name: '数据管理',
						icon: '/static/shopAdmin.png',
						// id:4,
						open: false,
						page: [{
								name: '数据统计',
								id: 0
							},
							
						]
					},
					{
						name: '人员管理',
						icon: '/static/personAdmin.png',
						// id:1,
						open: false,
						page: [{
								name: '用户管理',
								id: 1
							},
							{
								name: '登录日志',
								id: 2
							}
						]
					},
					{
						name: '帖子管理',
						icon: '/static/shopAdmin.png',
						// id:4,
						open: false,
						page: [{
								name: '帖子管理',
								id: 3
							},
							{
								name: '评论管理',
								id: 4
							},
						]
					},
					{
						name: '计划管理',
						icon: '/static/shopAdmin.png',
						// id:4,
						open: false,
						page: [

							{
								name: '计划概述',
								id: 5
							},
							{
								name: '通用计划管理',
								id: 6
							},
							{
								name: '健身计划管理',
								id: 7
							},
							{
								name: '学习计划管理',
								id: 8
							},
						]
					},

				],
				//登录日志数据
				LoginList:[
					{
						id: 1,
						userID: 1,
						ip_Address: null,
						ie: "ie",
						os: "os",
						createDate: "2024-07-15",
						log_Content: null,
					},
				],
				loginNum: 1,
				PageNum_login: 1,
				// 人员管理数据
				PersonList: [{
						id: 1,
						username: "SDF",
						password: "密码",
						userIcon: "头像",
						userCreateDate: "2024",
						gender: "性别",
						address: "湖北",
						userIntro: "哈哈哈"
					},
				],
				userNum: 1,
				PageNum_user: 1,

				// 帖子管理数据end
				posterList: [{
					id: 1,
					posterHeadline: "posterHeadline",
					posterDetail: "posterDetail",
					posterPicture: "posterPicture",
					posterDate: "posterDate",
					userID: "userID",
					planID: "planID"
				}],
				posterNum: 1,
				PageNum_poster: 1,
				//评论管理数据
				CommentList: [{
					id: 1,
					commentDetail: 'commentDetail',
					commentDate: "commentDate",
					commentTime: "commentTime",
					posterID: "posterID",
					userID: "userID"
				}],
				commentNum: 1,
				PageNum_comment: 1,
				// 商品管理数据
				ShopList: [],
				Num_shop: 1,
				PageNum_shop: 1,
				// 商品管理数据end
				pageList: [],
				AdminList: [],

				RecomList: [],

				//计划概述数据
				PageNum_plan: 1,
				Num_plan: 100,
				PlanList: [{
						id: 1,
						planTitle: '睡觉',
						planInfo: '就要睡觉',
						planStatus: '已打卡',
						createrID: 3
					},


				],				
				//计划概述数据end
				
				//通用计划概述
				commonPlanList:[],
				PageNum_commonPlan:1,
				Num_commonPlan:100,
				//通用计划概述end
				
				//健身计划
				fitPlanList:[],
				PageNum_fitPlan:1,
				Num_fitPlan:100,
				//健身计划end
				
				//学习计划
				studyPlanList:[],
				PageNum_studyPlan:1,
				Num_studyPlan:100,
				//学习计划end
			}
		},
		onLoad() {
			this.fetchlogin();
			this.fetchcomment();
            this.fetchposter();
			this.fetchuser();
			//楚河汉界
			this.fetchPlan();
			this.fetchCommonPlan();
			this.fetchFitPlan();
			this.fetchStudyPlan();

		},
		methods: {
			fetchStudyPlan(){
				const url = `/api/habit_former/admin/study_plan?pointer=1&pageSize=10`
				console.log(url);
				uni.request({
					url: url,
					method: 'GET',
					success: (res) => {
						console.log(res);
						if (res.data && res.data.code === 200) {
							const plans = res.data.data.records;
							this.PageNum_studyPlan=res.data.data.pages;
							this.Num_studyPlan = res.data.data.total;
							this.studyPlanList = plans.map(plan => ({
								id: plan.studyPlanItemID,
								studySubject:plan.studySubject,
								studyContent:plan.studyContent,
								planStatus: plan.status,
								studyTime:plan.studyTime,
								planID: plan.planID,
								planDate:plan.dateShow
							}));
							console.log(this.studyPlanList);
						} else {
							console.error('Failed to fetch commonplans:', res.data);
						}
					},
					fail: (err) => {
						console.error('Failed to update commonplan:', err);
					},
				});
			},
			fetchFitPlan(){
				const url = `/api/habit_former/admin/fit_plan?pointer=1&pageSize=10`
				console.log(url);
				uni.request({
					url: url,
					method: 'GET',
					success: (res) => {
						console.log(res);
						if (res.data && res.data.code === 200) {
							const plans = res.data.data.records;
							this.PageNum_fitPlan=res.data.data.pages;
							this.Num_fitPlan = res.data.data.total;
							this.fitPlanList = plans.map(plan => ({
								id: plan.fitPlanItemID,
								fitItemName:plan.fitItemName,
								fitType:plan.fitType,
								planStatus: plan.status,
								groupNum:plan.groupNum,
								numPerGroup:plan.numPerGroup,
								timePerGroup:plan.timePerGroup,
								planID: plan.planID,
								planDate:plan.dateShow
							}));
							console.log(this.fitPlanList);
						} else {
							console.error('Failed to fetch commonplans:', res.data);
						}
					},
					fail: (err) => {
						console.error('Failed to update commonplan:', err);
					},
				});
			},
			fetchCommonPlan(){
				const url = `/api/habit_former/admin/daily_plan?pointer=1&pageSize=10`
				console.log(url);
				uni.request({
					url: url,
					method: 'GET',
					success: (res) => {
						console.log(res);
						if (res.data && res.data.code === 200) {
							const plans = res.data.data.records;
							this.PageNum_commonPlan=res.data.data.pages;
							this.Num_commonPlan = res.data.data.total;
							this.commonPlanList = plans.map(plan => ({
								id: plan.dailyPlanID,
								planDetail: plan.planDetail,
								planStatus: plan.status,
								planID: plan.planID,
								planDate:plan.dateShow
							}));
							console.log(this.commonPlanList);
						} else {
							console.error('Failed to fetch commonplans:', res.data);
						}
					},
					fail: (err) => {
						console.error('Failed to update commonplan:', err);
					},
				});
			},
			fetchPlan() {
				const url = `/api/habit_former/admin/plan?pointer=1&pageSize=10`
				console.log(url);
				uni.request({
					url: url,
					method: 'GET',
					success: (res) => {
						console.log(res);
						if (res.data && res.data.code === 200) {
							const plans = res.data.data.records;
							this.PageNum_plan=res.data.data.pages;
							this.Num_plan = res.data.data.total;
							this.PlanList = plans.map(plan => ({
								id: plan.planID,
								planTitle: plan.planName,
								planInfo: plan.planInfo,
								planStatus: plan.status,
								createrID: plan.userID,
								planDate:plan.planDateShow
							}));
							console.log(this.PlanList);
						} else {
							console.error('Failed to fetch plans:', res.data.message);
						}
					},
					fail: (err) => {
						console.error('Failed to update plan:', err);
					},
				});
			},
			menu_change: function(e) {
				var that = this
				that.menu_id = e.id
				that.name = e.name
			},
			search: function() {
				var that = this
				uni.request({
					url: 'https://hn216.api.yesapi.cn/',
					method: "POST",
					header: {},
					data: {
						model_name: 'car_person',
						where: '[["user_num", "LIKE","' + that.search_word + '"]]',
						app_key: '0B4163C86181759DD5DE6C761AF719A5',
						service: 'App.Table.FreeQuery',
						perpage: 10, //每一页12个数据
						page: 1 //第几页
					},

					success: function(res) {
						console.log(res)
						that.PersonList = res.data.data.list
						console.log(that.PersonList)
					}
				})
				uni.request({
					url: 'https://hn216.api.yesapi.cn/',
					method: "POST",
					data: {
						model_name: 'car_person',
						where: '[["user_num", "LIKE","' + that.search_word + '"]]',
						app_key: '0B4163C86181759DD5DE6C761AF719A5',
						service: 'App.Table.FreeQuery',
						perpage: 10000, //每一页12个数据

					},
					success: function(res) {
						that.Num = res.data.data.list.length
						that.PageNum = Math.ceil(that.Num / 10); //向上整除
						console.log(that.PageNum)
					}
				})
			},
			add_sure: function() {
				var that = this
				console.log(that.accout)
				// 手机号正则
				if (!(/^1(3|4|5|6|7|8|9)\d{9}$/.test(that.add_accout))) {
					uni.showToast({
						icon: 'none',
						title: '手机号不正确'
					});
					return;
				} else {
					// 密码正则
					if (!(/^\d{6}$/.test(that.add_password))) {
						uni.showToast({
							icon: 'none',
							title: '密码不是六位数字！'
						});
						return;
					} else {
						uni.request({
							url: 'https://hn216.api.yesapi.cn/?s=App.Table.CheckCreate',
							data: {
								model_name: 'car_person',
								app_key: '0B4163C86181759DD5DE6C761AF719A5',
								service: 'App.Table.CheckCreate',
								data: {
									'user_num': that.add_accout,
									'user_pass': that.add_password,
								},
								check_field: "user_num",
							},

							success: function(res) {
								console.log('成功')
								console.log(res)
								that.add_accout = ''
								that.add_password = ''
								that.$refs.popup1.close()
								uni.showToast({
									title: '添加成功！',
									icon: 'none'
								})
								that.refresh()
							}
						})
					}
				}
			},
			add_cancel: function() {
				this.$refs.popup1.close()
			},
			add_data: function() {
				this.$refs.popup1.open()
			},
			// cancel_choose:function(){
			// 	var that = this

			// 	that.choose_all_ = false
			// 	that.checkbox = false
			// 	console.log(that.choose_all_)
			// },
			delete_all: function() {
				var that = this
				that.choose_all_ = false
				that.checkbox = false

				if (that.checkbox_status.length == 0 && that.checkbox == false) {
					uni.showToast({
						title: '未选中任何行',
						icon: 'none'
					})
				} else {
					uni.showModal({
						content: '确定要删除吗？',
						success: function(res) {
							if (res.confirm) {
								console.log('用户点击确定');
								console.log(that.checkbox_status)
								if (that.checkbox_status.length == 0) {
									console.log(1)
									console.log(that.PersonList)
									console.log(that.checkbox)
									if (that.checkbox == true) {
										console.log(2)

										for (var i = 0; i < that.PersonList.length; i++) {
											console.log(that.PersonList[i].id)
											uni.request({
												url: 'https://hn216.api.yesapi.cn/?s=App.Table.FreeDelete',
												method: "POST",
												data: {
													model_name: 'car_person',
													app_key: '0B4163C86181759DD5DE6C761AF719A5',
													service: 'App.Table.FreeDelete',
													where: '[["id", "=","' + that.PersonList[i]
														.id + '"]]',
												},
												success: function(res) {
													console.log(res)
													that.refresh()
												}
											})
										}
										uni.showToast({
											icon: 'none',
											title: '删除成功'
										});
										that.refresh()
										that.checkbox = false
									}
								} else {
									for (var i = 0; i < that.checkbox_status.length; i++) {
										uni.request({
											url: 'https://hn216.api.yesapi.cn/?s=App.Table.FreeDelete',
											method: "POST",
											data: {
												model_name: 'car_person',
												app_key: '0B4163C86181759DD5DE6C761AF719A5',
												service: 'App.Table.FreeDelete',
												where: '[["id", "=","' + that.checkbox_status[i] +
													'"]]',
											},
											success: function(res) {
												that.refresh()
											}
										})
									}
									that.checkbox = false
									uni.showToast({
										icon: 'none',
										title: '删除成功'
									});

								}
							} else if (res.cancel) {
								console.log('用户点击取消');
							}
						}
					});
				}


			},
			checkbox_change: function(e) {
				this.checkbox_status = e.detail.value
				console.log(this.checkbox_status)


			},
			choose_all: function() {
				if (this.checkbox == false) {
					this.checkbox = true
					this.choose_all_ = true
					this.checkbox_status = []
					console.log(this.checkbox)
				} else {
					this.checkbox = false
					this.choose_all_ = false
					this.checkbox_status = []
					console.log(this.checkbox)
				}
			},
			delete_detail: function(e) {
				var that = this
				uni.showModal({
					content: '确定要删除吗？',
					success: function(res) {
						if (res.confirm) {
							console.log('用户点击确定');

							uni.request({
								url: 'https://hn216.api.yesapi.cn/?s=App.Table.FreeDelete',
								method: "POST",
								data: {
									model_name: 'car_person',
									app_key: '0B4163C86181759DD5DE6C761AF719A5',
									service: 'App.Table.FreeDelete',
									where: '[["id", "=","' + e.id + '"]]',
								},
								success: function(res) {
									console.log(res)

									that.checkbox_status = []
									uni.showToast({
										icon: 'none',
										title: '删除成功'
									});

									that.refresh()
								}
							})

						} else if (res.cancel) {
							console.log('用户点击取消');

							that.checkbox_status = []
						}
					}
				});
			},
			refresh() {

				console.log(this.checkbox)

				var that = this

				uni.request({
					url: 'https://hn216.api.yesapi.cn/',
					method: "POST",
					data: {
						model_name: 'car_person',
						where: '[["user_num", "LIKE","' + that.search_word + '"]]',
						app_key: '0B4163C86181759DD5DE6C761AF719A5',
						service: 'App.Table.FreeQuery',
						perpage: 10, //每一页12个数据
						page: that.NowPage, //第几页
						// order: ["id DESC"],
					},
					success: function(res) {
						// console.log(res.data.data.list)
						that.PersonList = res.data.data.list
					}
				})
				uni.request({
					url: 'https://hn216.api.yesapi.cn/',
					method: "POST",
					data: {
						model_name: 'car_person',
						where: '[["user_num", "LIKE","' + that.search_word + '"]]',
						app_key: '0B4163C86181759DD5DE6C761AF719A5',
						service: 'App.Table.FreeQuery',
						perpage: 10000, //每一页12个数据

					},
					success: function(res) {
						that.Num = res.data.data.list.length
						that.PageNum = Math.ceil(that.Num / 10); //向上整除
						console.log(that.PageNum)
					}
				})
			},
			alter_cancel() {
				this.$refs.popup.close()
			},
			alter_sure() {
				var that = this
				console.log(that.accout)
				// 手机号正则
				if (!(/^1(3|4|5|6|7|8|9)\d{9}$/.test(that.accout))) {
					uni.showToast({
						icon: 'none',
						title: '手机号不正确'
					});
					return;
				} else {
					// 密码正则
					if (!(/^\d{6}$/.test(that.password))) {
						uni.showToast({
							icon: 'none',
							title: '密码不是六位数字！'
						});
						return;
					} else {
						uni.request({
							url: 'https://hn216.api.yesapi.cn/?s=App.Table.CheckCreateOrUpdate',
							data: {
								model_name: 'car_person',
								app_key: '0B4163C86181759DD5DE6C761AF719A5',
								service: 'App.Table.CheckCreateOrUpdate',
								data: {
									'user_num': that.accout,
									'user_pass': that.password,
									'id': that.person_id
								},
								check_field: "id",

							},

							success: function(res) {
								console.log('成功')
								console.log(res)
								that.$refs.popup.close()
								uni.showToast({
									title: '修改成功！',
									icon: 'none'
								})
								that.refresh()
							}
						})
					}
				}



			},
			close() {
				this.$refs.popup.close()
			},
			confirm0() {
				this.input_confirm = 0
				console.log(this.input_confirm)
			},
			confirm1() {
				this.input_confirm = 1
				console.log(this.input_confirm)
			},
			alter: function(e) {
				this.$refs.popup.open()
				console.log(e)
				this.password = e.user_pass
				this.accout = e.user_num
				this.add_time = e.add_time
				this.person_id = e.id
			},

			change_page: function(e) {
				console.log(e)
				var that = this
				that.NowPage = e
				that.checkbox = false
				that.checkbox_status = []
				uni.request({
					url: 'https://hn216.api.yesapi.cn/',
					method: "POST",
					data: {
						model_name: 'car_person',
						where: '[["user_num", "LIKE","' + that.search_word + '"]]',
						app_key: '0B4163C86181759DD5DE6C761AF719A5',
						service: 'App.Table.FreeQuery',
						perpage: 10, //每一页12个数据
						page: e, //第几页
						// order: ["id DESC"],
					},
					success: function(res) {
						// console.log(res.data.data.list)
						that.PersonList = res.data.data.list
						console.log(that.PersonList)
					}
				})
			},
			page_delete: function() {
				var that = this
				if (that.NowPage <= 1) {
					console.log('不合格')
					alert('已经是首页了！')
				} else {
					that.NowPage = that.NowPage - 1
					uni.request({
						url: 'https://hn216.api.yesapi.cn/',
						method: "POST",
						data: {
							model_name: 'car_person',
							where: '[["user_num", "LIKE","' + that.search_word + '"]]',
							app_key: '0B4163C86181759DD5DE6C761AF719A5',
							service: 'App.Table.FreeQuery',
							perpage: 10, //每一页12个数据
							page: that.NowPage, //第几页
							// order: ["id DESC"],
						},
						success: function(res) {
							// console.log(res.data.data.list)
							that.PersonList = res.data.data.list
							console.log(that.PersonList)
						}
					})
				}
			},
			page_add: function() {
				var that = this
				if (that.NowPage >= that.PageNum) {
					console.log('不合格')
					alert('已经是尾页了！')
				} else {
					that.NowPage = that.NowPage + 1
					uni.request({
						url: 'https://hn216.api.yesapi.cn/',
						method: "POST",
						data: {
							model_name: 'car_person',
							where: '[["user_num", "LIKE","' + that.search_word + '"]]',
							app_key: '0B4163C86181759DD5DE6C761AF719A5',
							service: 'App.Table.FreeQuery',
							perpage: 10, //每一页12个数据
							page: that.NowPage, //第几页
							// order: ["id DESC"],
						},
						success: function(res) {
							// console.log(res.data.data.list)
							that.PersonList = res.data.data.list
							console.log(that.PersonList)
						}
					})
				}
			},

			fetchuser: function() {
				const url=`/api/habit_former/admin/user?pointer=${this.NowPage}&pageSize=10`;
				console.log(url);
			    uni.request({
			      url: url,
			      method: 'GET',
			      success: (res) => {
			        if (res.data.code === 200) {
					  this.userNum=res.data.data.total;
					  this.PageNum_user=res.data.data.pages;
			          this.PersonList = res.data.data.records.map(record => ({
			            id: record.userID,
			            username: record.username,
			            password: record.password,
			            userIcon: record.userIcon,
			            userCreateDate: record.userCreateDate,
			            gender: record.gender,
			            address: record.address,
			            userIntro: record.userIntro
			          }));
			        } else {
			          console.error('Failed to fetch user data:', res.data.message);
			        }
			      },
			      fail: (err) => {
			        console.error('Request failed:', err);
			      }
			    });
			  },
			fetchposter: function() {
				const url=`/api/habit_former/admin/poster?pointer=${this.NowPage}&pageSize=10`;

			    uni.request({
			      url: url,
			      method: 'GET',
			      success: (res) => {
					console.log(res);
			        if (res.data.code === 200) {
					  this.posterNum=res.data.data.total;
					  this.PageNum_poster=res.data.data.pages;
			          this.posterList = res.data.data.records.map(record => ({
			            id: record.posterID,
			            posterHeadline: record.posterHeadline,
			            posterDetail: record.posterDetail,
			            // posterPicture: record.posterPicture,
			            posterDate: record.posterDate,
			            userID: record.userID,
			            planID: record.planID
			          }));
			        } else {
			          console.error('Failed to fetch user data:', res.data.message);
			        }
			      },
			      fail: (err) => {
			        console.error('Request failed:', err);
			      }
			    });
			  },
			fetchcomment: function() {
				const url=`/api/habit_former/admin/comment?pointer=${this.NowPage}&pageSize=10`;
				console.log(url);
			    uni.request({
			      url: url,
			      method: 'GET',
			      success: (res) => {
			        if (res.data.code === 200) {
					  this.commentNum=res.data.data.total;
					  this.PageNum_comment=res.data.data.pages;
			          this.CommentList = res.data.data.records.map(record => ({
			            id: record.commentID,
			            commentDetail: record.commentDetail,
			            commentDate: record.commentDate,
			            commentTime: record.commentTime,
			            posterID: record.posterID,
			            userID: record.userID
			          }));
			        } else {
			          console.error('Failed to fetch user data:', res.data.message);
			        }
			      },
			      fail: (err) => {
			        console.error('Request failed:', err);
			      }
			    });
			  },
			fetchlogin: function() {
				const url=`/api/habit_former/admin/login_log?pointer=${this.NowPage}&pageSize=10`;
				console.log(url);
			    uni.request({
			      url: url,
			      method: 'GET',
			      success: (res) => {
			        if (res.data.code === 200) {
					  this.loginNum=res.data.data.total;
					  this.PageNum_login=res.data.data.pages;
			          this.LoginList = res.data.data.records.map(record => ({
			            id: record.logID,
			            ip_Address: record.ip_Address,
			            ie: record.ie,
			            createDate: record.createDate,
			            os: record.os,
			            userID: record.userID,
						log_Content:record.log_Content,
			          }));
			        } else {
			          console.error('Failed to fetch login data:', res.data.message);
			        }
			      },
			      fail: (err) => {
			        console.error('Request failed:', err);
			      }
			    });
			  },
		}
	}
</script>

<style>
	.add_color {
		background-color: #1890FF;

	}

	.add_color:hover {
		background-color: #46A6FF;
	}

	.admin_pic {
		width: 180upx;
		height: 50upx;
		padding: 20upx;
	}

	.admin_pic:hover {
		background-color: #2C405A;
	}

	.arrow {
		height: 20upx;
		width: 20upx;

		margin-left: auto;
	}

	.arrow1 {
		height: 18upx;
		width: 18upx;

	}

	.choose_detail {
		padding: 20upx 20upx 20upx 40upx;
		width: 160upx;
		display: flex;
		flex-direction: row;
		color: #FFFFFF;
		font-size: 15px;
		align-items: center;
		background-color: #1890FF;
	}

	.detail {
		padding: 20upx 20upx 20upx 40upx;
		width: 160upx;
		display: flex;
		flex-direction: row;
		color: #FFFFFF;
		font-size: 15px;
		align-items: center;

	}

	.detail:hover {
		background-color: #1890FF;
	}

	.list_detail {
		border-bottom: 1px solid #EBEEF5;
		display: flex;
		flex-direction: row;
		width: 100%;
		padding: 10upx;
	}

	.list_detail:hover {
		background-color: #F5F7FA;
	}

	.alter {
		color: #1890FF;
	}

	.alter:hover {
		text-decoration: underline;
		color: #DD524D;
	}

	.delete {
		color: #1890FF;
		margin-left: 10upx;
	}

	.delete:hover {
		text-decoration: underline;
		color: #DD524D;
	}

	.left {
		background-color: #F4F4F5;
		width: 15upx;
		height: 15upx;
		padding: 10upx;
	}

	.page {
		color: #FFFFFF;
		background-color: #1890FF;
		width: 32upx;
		height: 32upx;
		font-size: 15px;
		border-radius: 3upx;
		text-align: center;
		justify-content: center;
		display: flex;
		align-items: center;
		margin-left: 10upx;
	}

	.nopage {
		color: #FFFFFF;
		background-color: #F4F4F5;
		width: 32upx;
		height: 32upx;
		font-size: 15px;
		border-radius: 3upx;
		text-align: center;
		justify-content: center;
		display: flex;
		align-items: center;
		margin-left: 10upx;
		color: #606270;
	}

	.right {
		margin-left: 10upx;
		background-color: #F4F4F5;
		width: 15upx;
		height: 15upx;
		padding: 10upx;
	}

	.input_account {
		padding: 5upx 15upx 5upx 15upx;
		border: 1px solid #DCDFE6;
		width: 250upx;
		font-size: 13px;
		margin-left: 20upx;
	}

	.input_account:hover {
		border: 1px solid #C8C7CC;
	}

	.input_account1 {
		padding: 5upx 15upx 5upx 15upx;
		border: 1px solid #DCDFE6;
		width: 227upx;
		font-size: 13px;
		margin-left: 20upx;
	}

	.input_confirm {
		border: 1px solid #1890FF;
		padding: 5upx 15upx 5upx 15upx;
		width: 250upx;
		font-size: 13px;
		margin-left: 20upx;
	}

	.back_color {
		background-color: #FF4D4F;
	}

	.back_color:hover {
		background-color: #FF7172;
	}
</style>